package xhwl.insurance.http.api;

import com.google.gson.Gson;

import okhttp3.RequestBody;
import rx.Observable;
import xhwl.android.common.util.SPUtil;
import xhwl.insurance.http.ApiService;
import xhwl.retrofitrx.BaseApi;

/**
 * Created by admin on 2017/6/6.
 */

public class SubmitFileApi extends BaseApi {

    SubmitFileApiReq req;

    public SubmitFileApi(String c_type,String person_age, String person_idcard, String person_mobile,
                         String person_name, String person_sex, String sale_mobile,
                         String sale_type, String sale_userid, String yw_id,
                         String card_number, String card_number_pic,
                         String hz_money, String card_front, String card_back, String sale_date) {
        req = new SubmitFileApiReq(c_type,person_age, person_idcard, person_mobile,
                person_name, person_sex, sale_mobile,
                sale_type, sale_userid, yw_id,
                card_number, card_number_pic,
                hz_money, card_front, card_back, sale_date);
        setCancle(false);
        setShowErrorMsg(false);
    }

    @Override
    protected Observable getObservable() {
        RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(req));
        return retrofit.create(ApiService.class).submitfile(requestBody);
    }

    public class SubmitFileApiReq {

        /**
         * person_age : 28//
         * person_idcard : 111327198903262819//
         * person_mobile : 18810718149//
         * person_name : 王兵//
         * person_sex : 0//
         * sale_mobile : 18810718149//
         * sale_type : 15//
         * sale_userid : 551105
         * yw_id : 1//
         * member_mobile : 13292796222//
         * card_number : 10021212121212//
         * card_number_pic : 10021212121212//
         * hz_money : 100//
         * card_front : 12131312//
         * card_back : 12121212//
         * sale_date : 2001-01-01
         */

        private String person_age;
        private String person_idcard;
        private String person_mobile;
        private String person_name;
        private String person_sex;
        private String sale_mobile;
        private String sale_type;
        private String sale_userid;
        private String yw_id;
        private String member_mobile;
        private String card_number;
        private String card_number_pic;
        private String hz_money;
        private String card_front;
        private String card_back;
        private String sale_date;
        private String c_type;
        public SubmitFileApiReq(String c_type,String person_age, String person_idcard, String person_mobile,
                                String person_name, String person_sex, String sale_mobile,
                                String sale_type, String sale_userid, String yw_id,
                                String card_number, String card_number_pic,
                                String hz_money, String card_front, String card_back, String sale_date) {
            this.c_type=c_type;
            this.person_age = person_age;
            this.person_idcard = person_idcard;
            this.person_mobile = person_mobile;
            this.person_name = person_name;
            this.person_sex = person_sex;
            this.sale_mobile = sale_mobile;
            this.sale_type = sale_type;
            this.sale_userid = sale_userid;
            this.yw_id = yw_id;
            this.member_mobile = SPUtil.getPersonInfoSp().getString(SPUtil.SPPersonInfo.LINK_MOBILE, "");
            this.card_number = card_number;
            this.card_number_pic = card_number_pic;
            this.hz_money = hz_money;
            this.card_front = card_front;
            this.card_back = card_back;
            this.sale_date = sale_date;
        }
    }
}
